<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
			table{
				margin: 0px auto;
				text-align: center;
			}
		</style>
	</head>
	<body>
		<table border="1" cellspacing="0" cellpadding="0">
			
			<tr>
				<td>手机号码</td>
				<td><input type="text" id="phoneId" value="15766472116" /></td>
				
			</tr>
			
			<tr>
				<td>密码：</td>
				<td><input type="password" id="password" value="123" /></td>
				
			</tr>
			<tr>
				<td colspan="2"><input type="button" id="but01" value="注册" /></td>
			</tr>
			
		</table>
		<span id="mm"></span>
		<a href="${pageContext.request.contextPath}/login/login.jsp">去登陆</a>
	</body>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.js" ></script>
	<script type="text/javascript">
		
	/* http://localhost:8090/liuhao/login/reg.jsp */
		
		$('#but01').click(function(){
			
			
			
			var lhName=$('#phoneId').val();
			var lhPassword=$('#password').val();
			
			var url="${pageContext.request.contextPath}/user.do?method=regUser";
			$.ajax({
				  'type': "post",
				  'url': url,
				  'dataType': "json",
				  'data':{
					  'lhName':lhName,
					  'lhPassword':lhPassword,
				  },
				  success: function(msg){
					  
					  /* Object {code: "200"} */
					 	 console.log(msg);
					  if(200==msg.code){
						  /* window.onload.href="login.html"; */
						  $('#mm').html("注册成功");
						  setInterval(go, 1000); 
					  }else{
						  $('#mm').html("该用户已经注册");
					  }
					   }
				});
			
		});
		
		function go(){ 
			location.href=" http://localhost:8090/liuhao/login/login.jsp"; 
			} 

		
	</script>
	
</html>